$(function() {
	var _loginForm = $('#loginForm2');
	var _username = $("input[name='username']", _loginForm),
		_password = $("input[name='password']", _loginForm);
	//检查输入，还没应用
	function checkInput(obj) {
		if (obj.val() == '' || null) {
			$(this).css('border-color', 'red');
			return false;
		} else {
			$(this).css('border-color', '#e5e5e5');
		}
	}
	// $(document).keypress(function(event){
	// 	var event = event || window.event;
	// 	console.log(event.keyCode);
	// 	if(event.keyCode === 13){
	// 		event.preventDefault();
	// 		return false;
	// 	}
	// })
	_username.keypress(function(event) {
		var event = event || window.event;
		if (event.keyCode == 13) {
			event.preventDefault();
			$("input[name='submitLogin']", _loginForm).click();
			return false;
		}

	});
	_password.keypress(function(event) {
		var event = event || window.event;
		if (event.keyCode == 13) {
			event.preventDefault();
			$("input[name='submitLogin']", _loginForm).click();
			return false;
		}

	});

	$("input[name='submitLogin']", _loginForm).click(function() {

		//alert(_username.val());	
		//alert(_password.val());							
		$.ajax({
			type: "POST",
			url: "/User/login",
			data: {
				"username": _username.val(),
				"password": _password.val()
			},
			success: function(data) {
				//console.log(data.info);
				layer.msg(data.info);
				if (true === data.status) {
					window.location = "/Index/index";
				}

			},



		});
		return false;
	});



})